<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Insert title here</title>
	<link href="css/bootstrap.min.css" rel="stylesheet" />
	<script src="js/jquery-3.2.0.min.js" ></script>
	<script src="js/bootstrap.min.js" ></script>
	<script src="js/config.js" ></script>
	<script src="js/common.js" ></script>
</head>
<body>
	<ul id="nav" class="nav nav-tabs">
	</ul>
	<div class="panel panel-default">
		<!-- Table -->
		<table class="table">
			<thead>
				<tr>
					<th>班级名称</th>
					<th>学生名称</th>
					<th>课程地址</th>
					<th>老师名称</th>
					<th>实验名称</th>
					<th>出勤情况</th>
					<th>分数</th>
				</tr>
			</thead>
			<tbody id="tbody">
			
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
		console.log('in classStudent html page');
		var $nav = $('#nav');
		var $tbody = $('#tbody');
		
		var initTbody = function(data){
			$tbody.html("");
			for(i in data){
				var $tr = $('<tr></tr>');
				$tr.append('<td>'+data[i].cname+'</td>');
				$tr.append('<td>'+data[i].sname+'</td>');
				$tr.append('<td>'+data[i].rptname+'</td>');
				$tr.append('<td>'+data[i].tname+'</td>');
				$tr.append('<td>'+data[i].pname+'</td>');
				$tr.append('<td>'+data[i].aname+'</td>');
				$tr.append('<td>'+data[i].score+'</td>');
				$tbody.append($tr);
			}
		}
		var initNav = function(data){
			for(i in data){
				$nav.append('<li role="presentation"><a href="JavaScript:void(0);" cid="'+data[i]['id']+'">'+data[i]['name']+'</a></li>');
			}
			var $lis = $nav.find('li'); 
			$lis.on('click',function(){
				$lis.removeClass('active');
				$(this).addClass('active');
				var cid = $(this.innerHTML).attr('cid');
				$.get('SuperAdmin_classStudent?cid='+cid,{},function(res){
					var data = isSuc(res);
					if(data){
						initTbody(data);
					}else{
						alert(res.msg);
					}
				},'json');
			});
		}
		$.get(BASE_URL + "/classSelect",{},function(res){
			console.log(res);
			var data = isSuc(res);
			if(data){
				initNav(data);
			}else{
				alert(res.msg);
			}
		},'json');
	</script>
</body>
</html>